<?php

if(!defined('_HTML_SET_LOCATON_')) {
define('_HTML_SET_LOCATON_', 1);

function itstock_page_set_location($id, $type, $inputs = null) {
  if(is_null($inputs)) {
    $inputs = array('location' => 'location_id','cpu' => 'cpu_id','warehouse' => 'warehouse_id');
  }
  switch ($type) {
    case 'cpu':
      $fields = array(
        'building' => 'Building',
        'department' => 'Department',
        'floor' => 'Floor',
        'spot' => 'Spot',
        'cpu' => 'Computer Case'
      );
      break;
    case 'location':
      $fields = array(
        'building' => 'Building',
        'department' => 'Department',
        'floor' => 'Floor',
        'spot' => 'Spot'
      );
      break;
    case 'warehouse':
      $fields = array(
        'building' => 'Building',
        'floor' => 'Floor',
        'warehouse' => 'Warehouse',
      );
      break;
    default:
      exit();
  }
  itstock_structure($data, $type);
  $data['where'][0] = "$data[table].id=".itstock_decode($id);
  if(itstock_search_all($data)){
    echo '<dl>';
    foreach($fields as $field => $name) {
      echo "<dt>".$name.":</dt><dd>".$data['data'][0][$field]."</dd>\n";
    }
    echo '</dl>';
    ?>
      <input type="hidden" value="<?php echo $id; ?>" id="<?php echo $inputs[$type]; ?>" name="<?php echo $inputs[$type]; ?>">
    <?php
  }
}

}
?>
